// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

let self = this;
var AU = require("AudioUtils");
cc.Class({
    extends: cc.Component,

    properties: {
	},

    init: function(){
    	if(cc.sys.isMobile && typeof (wx) !== "undefined") { //小游戏移动设备环境下
    		wx.showShareMenu({
    			withShareTicket: true
    		});//开启转发按钮
    		//监听右上角的分享调用
    		wx.onShareAppMessage(function(res){
				return {
					title: "快来玩,充钱不卡...",
					imageUrl: REMOTE_IMG_1,
					success(res){
						console.log("转发成功!!!")
					},
					fail(res){
						console.log("转发失败!!!")
					} 
				}
			});
    	}
    	
		var bgRank = cc.find('Canvas/bg_rank');
		bgRank.active = false;
		var bgSetup = cc.find('Canvas/bg_setup');
		bgSetup.active = false;
	},
	
    onLoad () {
    	self = this;
    	self.init();
    	/*console.log("1234");
    	console.log(AU.inst);
    	console.log(AU.inst.getEffectVolume());*/
    	//AU.inst.playMusic("resources/audio/space_trip.mp3",true);
    	//AU.inst.reLoadRes("/audio");
    	/*cc.loader.loadRes("audio/bullet_shot1", function (err, res) {
    		cc.audioEngine.play(res,true,1);
			if(err) {
                cc.error("【音频】资源加载错误");
                return ;
            }
		});*/
		//AU.inst.reLoadRes("");
    	//AU.inst.playMusic("audio/space_trip",true);
    	//AU.inst.playEffect1(MUSIC_SPACE_TRIP,true);
    	//AU.inst.playEffect2(MUSIC_SPACE_TRIP,true);
    },
    
    shareFun(){
 
        // 分享要传递的参数   
        var nick = "小红";
        var gender = "女";
        var city = "北京";
 
        //分享要显示图片
        var shareImgUrl = "https://www.xianqiju.cn/all-res/caihongjuntuan/start_btn.png";
        wx.shareAppMessage({
          title: "快来玩,充钱不卡...",      //分享标题
          imageUrl: shareImgUrl,
          //query: "nick=" + nick + "&gender=" + gender + "&city=" + city, // 别人点击链接时会得到的数据
          success: function success(res) {
            console.log("分享成功", res);
            wx.showShareMenu({
                // 要求小程序返回分享目标信息
                withShareTicket: true 
            });
          },
          fail: function fail(res) {
            console.log("分享失败", res);
          }
        });
    },

    start () {

    },

    // update (dt) {},
});
